package com.celan.year2023.month03.day29;

import java.util.HashSet;

/**
 * @author Celan
 * @ClassName Solution
 * @description: TODO
 * @date 2023/04/29
 * @version: 1.0
 */
class Solution {
    public boolean equalFrequency(String word) {
        int[] dic = new int[26];
        for (char c : word.toCharArray()) {
            dic[c - 'a']++;
        }
        for (int i = 0; i < 26; i++) {
            if (dic[i] == 0) continue;
            dic[i]--;
            HashSet<Integer> set = new HashSet<>();
            for (int cnt : dic) {
                if (cnt != 0) set.add(cnt);
            }
            if (set.size() == 1) return true;
            dic[i]++;
        }
        return false;
    }
}
